diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bcb6f00 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,59 @@ +name: release +on: + push: + branches: [main] +jobs: + test: + name: Test for release + if: startsWith(github.event.head_commit.message, '[release:minor]') || + startsWith(github.event.head_commit.message, '[release:major]') || + startsWith(github.event.head_commit.message, '[release:patch]') + uses: flowr-analysis/flowr-r-adapter/.github/workflows/test.yml@main + + release: + runs-on: ubuntu-latest + needs: [test] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ secrets.RELEASE_TOKEN }} + - name: Configure git user + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + + - name: Install R + uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.r-version }} + - name: Install dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: devtools, usethis + + - name: Bump version + id: version + run: | + step=$(echo "$MESSAGE" | sed -n -E 's/\[release:(patch|minor|major)].*/\1/p') + if [ -z "$step" ]; then + echo "fatal: Release step not found in commit message." + exit 1 + fi + + Rscript -e "usethis::use_version(\"$step\", push = TRUE)" + + new_version=$(sed -n -E "s/Version: (.*)/\1/p" DESCRIPTION) + echo "::set-output name=release_tag::$new_version" + env: + # putting the message into an env variable first sanitizes it + MESSAGE: ${{ github.event.head_commit.message }} + + - name: CRAN Release + run: Rscript -e 'devtools::release()' + + - name: GitHub release + uses: softprops/action-gh-release@v2 + with: + token: ${{ secrets.RELEASE_TOKEN }} + tag_name: ${{ steps.version.outputs.release_tag }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29784cb..3569ead 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,7 @@ on: pull_request: types: [opened, synchronize] branches: [main] + workflow_call: jobs: devtools-check: strategy: diff --git a/DESCRIPTION b/DESCRIPTION index 26b8fc8..5f503c7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,6 +13,6 @@ Imports: digest, jsonlite, rlang -Suggests: +Suggests: testthat (>= 3.0.0) Config/testthat/edition: 3 diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..204cddb --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# flowr 0.0.1 + +* Added a `NEWS.md` file to track changes to the package.