|
| 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 | + |
| 13 | + env: |
| 14 | + # See: https://github.com/fsaintjacques/semver-tool/releases |
| 15 | + SEMVER_TOOL_VERSION: 3.2.0 |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Set environment variables |
| 19 | + run: | |
| 20 | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable |
| 21 | + echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV" |
| 22 | + echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV" |
| 23 | +
|
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v2 |
| 26 | + with: |
| 27 | + fetch-depth: 0 |
| 28 | + |
| 29 | + - name: Create changelog |
| 30 | + uses: arduino/create-changelog@v1 |
| 31 | + with: |
| 32 | + tag-regex: '^v[0-9]+\.[0-9]+\.[0-9]+.*$' |
| 33 | + filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*' |
| 34 | + case-insensitive-regex: true |
| 35 | + changelog-file-path: ${{ env.CHANGELOG_PATH }} |
| 36 | + |
| 37 | + - name: Download semver tool |
| 38 | + id: download-semver-tool |
| 39 | + uses: carlosperate/[email protected] |
| 40 | + with: |
| 41 | + file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip |
| 42 | + location: ${{ runner.temp }}/semver-tool |
| 43 | + |
| 44 | + - name: Install semver tool |
| 45 | + run: | |
| 46 | + unzip \ |
| 47 | + -p \ |
| 48 | + "${{ steps.download-semver-tool.outputs.file-path }}" \ |
| 49 | + semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \ |
| 50 | + "${{ env.SEMVER_TOOL_PATH }}" |
| 51 | + chmod +x "${{ env.SEMVER_TOOL_PATH }}" |
| 52 | +
|
| 53 | + - name: Identify Prerelease |
| 54 | + id: prerelease |
| 55 | + run: | |
| 56 | + if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi |
| 57 | +
|
| 58 | + - name: Create Github release |
| 59 | + uses: ncipollo/release-action@v1 |
| 60 | + with: |
| 61 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + bodyFile: ${{ env.CHANGELOG_PATH }} |
| 63 | + draft: false |
| 64 | + prerelease: ${{ steps.prerelease.outputs.IS_PRE }} |
0 commit comments