Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Build a source tarball for any versioned release, attach it to a GitHub release
on:
push:
tags:
- 'v*'
workflow_dispatch:

name: Build release tarball

jobs:
release:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')

permissions:
contents: write

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
needs: build

- name: Build tarball
id: build
run: |
R CMD build .
PACKAGE="$(awk '/^Package: / { print $2 }' DESCRIPTION)"
VERSION="$(awk '/^Version: / { print $2 }' DESCRIPTION)"
TARBALL="${PACKAGE}_${VERSION}.tar.gz"
[ "v${VERSION}" = "${GITHUB_REF_NAME}" ] || { echo "::error::Tag ${GITHUB_REF_NAME} doesn't match DESCRIPTION version ${VERSION}"; exit 1; }
[ -f "${TARBALL}" ]
echo "tarball=${TARBALL}" >> "$GITHUB_OUTPUT"
# Release notes are the first section of NEWS.md, minus the header
awk 'NR > 1 && /^# / { exit } NR > 1 { print }' NEWS.md > release-notes.md

- uses: actions/upload-artifact@v4
with:
name: ${{ steps.build.outputs.tarball }}
path: ${{ steps.build.outputs.tarball }}

- name: Create / update GitHub release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1; then
gh release upload "$GITHUB_REF_NAME" "${{ steps.build.outputs.tarball }}" --clobber
else
gh release create "$GITHUB_REF_NAME" "${{ steps.build.outputs.tarball }}" \
--title "$GITHUB_REF_NAME" \
--notes-file release-notes.md \
--verify-tag
fi
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ release: release-description release-news
R CMD build .
#
sed -i 's/^Version: .*/Version: '"$(NEW_VERSION)-999"'/' DESCRIPTION
git commit -m "Development version $(NEW_VERSION)-999" DESCRIPTION
mv NEWS.md NEWS.md.o
/bin/echo -e "# $(PACKAGE) $(NEW_VERSION)-999:\n" > NEWS.md
cat NEWS.md.o >> NEWS.md
rm NEWS.md.o
git commit -m "Development version $(NEW_VERSION)-999" DESCRIPTION NEWS.md

release-description:
[ -n "$(NEW_VERSION)" ] # NEW_VERSION variable should be set
Expand All @@ -70,8 +74,14 @@ release-description:

release-news:
[ -n "$(NEW_VERSION)" ] # NEW_VERSION variable should be set
# Remove any -999 header
mv NEWS.md NEWS.md.o
head -1 NEWS.md.o | grep -qE '^\# $(PACKAGE).*-999:?$$' || head -2 NEWS.md.o > NEWS.md
tail -n +3 NEWS.md.o >> NEWS.md
rm NEWS.md.o
# Any news? Add new header if so
mv NEWS.md NEWS.md.o
head -1 NEWS.md.o | grep -E '^\# $(PACKAGE) ' || /bin/echo -e "# $(PACKAGE) $(NEW_VERSION):\n" > NEWS.md
head -1 NEWS.md.o | grep -qE '^\# $(PACKAGE) ' || /bin/echo -e "# $(PACKAGE) $(NEW_VERSION):\n" > NEWS.md
cat NEWS.md.o >> NEWS.md
rm NEWS.md.o

Expand Down
8 changes: 7 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# mfdb 7.3-99:
# mfdb 7.4-0-999:

## Documentation

* vignettes/import_hydrography_cmems: Rewritten to download data with CopernicusMarine, as RCMEMS is no longer available #80

# mfdb 7.4-0:

## Breaking Changes

Expand Down
Loading