|
| 1 | +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-tag.md |
| 2 | +name: Release |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - "v?[0-9]+.[0-9]+.[0-9]+*" |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | + env: |
| 16 | + # See: https://github.com/fsaintjacques/semver-tool/releases |
| 17 | + SEMVER_TOOL_VERSION: 3.2.0 |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Set environment variables |
| 21 | + run: | |
| 22 | + # See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable |
| 23 | + echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV" |
| 24 | + echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV" |
| 25 | +
|
| 26 | + - name: Checkout repository |
| 27 | + uses: actions/checkout@v3 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Create changelog |
| 32 | + uses: arduino/create-changelog@v1 |
| 33 | + with: |
| 34 | + tag-regex: '^v?[0-9]+\.[0-9]+\.[0-9]+.*$' |
| 35 | + filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*' |
| 36 | + case-insensitive-regex: true |
| 37 | + changelog-file-path: ${{ env.CHANGELOG_PATH }} |
| 38 | + |
| 39 | + - name: Download semver tool |
| 40 | + id: download-semver-tool |
| 41 | + uses: carlosperate/download-file-action@v2 |
| 42 | + with: |
| 43 | + file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip |
| 44 | + location: ${{ runner.temp }}/semver-tool |
| 45 | + |
| 46 | + - name: Install semver tool |
| 47 | + run: | |
| 48 | + unzip \ |
| 49 | + -p \ |
| 50 | + "${{ steps.download-semver-tool.outputs.file-path }}" \ |
| 51 | + semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \ |
| 52 | + "${{ env.SEMVER_TOOL_PATH }}" |
| 53 | + chmod +x "${{ env.SEMVER_TOOL_PATH }}" |
| 54 | +
|
| 55 | + - name: Identify Prerelease |
| 56 | + id: prerelease |
| 57 | + run: | |
| 58 | + if [[ \ |
| 59 | + "$( |
| 60 | + "${{ env.SEMVER_TOOL_PATH }}" get prerel \ |
| 61 | + "${GITHUB_REF/refs\/tags\//}" |
| 62 | + )" != \ |
| 63 | + "" \ |
| 64 | + ]]; then |
| 65 | + echo "IS_PRE=true" >> $GITHUB_OUTPUT |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Create Github release |
| 69 | + uses: ncipollo/release-action@v1 |
| 70 | + with: |
| 71 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + bodyFile: ${{ env.CHANGELOG_PATH }} |
| 73 | + draft: false |
| 74 | + prerelease: ${{ steps.prerelease.outputs.IS_PRE }} |
0 commit comments