|
| 1 | +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/release-go-task.md |
| 2 | +name: Release |
| 3 | + |
| 4 | +env: |
| 5 | + # As defined by the Taskfile's PROJECT_NAME variable |
| 6 | + PROJECT_NAME: aws-s3-integration |
| 7 | + # As defined by the Taskfile's DIST_DIR variable |
| 8 | + DIST_DIR: dist |
| 9 | + ARTIFACT_NAME: dist |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + tags: |
| 14 | + - "[0-9]+.[0-9]+.[0-9]+*" |
| 15 | + |
| 16 | +jobs: |
| 17 | + create-release-artifacts: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + |
| 26 | + - name: Create changelog |
| 27 | + uses: arduino/create-changelog@v1 |
| 28 | + with: |
| 29 | + tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$' |
| 30 | + filter-regex: '^\[(skip|changelog)[ ,-](skip|changelog)\].*' |
| 31 | + case-insensitive-regex: true |
| 32 | + changelog-file-path: "${{ env.DIST_DIR }}/CHANGELOG.md" |
| 33 | + |
| 34 | + - name: Install Task |
| 35 | + uses: arduino/setup-task@v1 |
| 36 | + with: |
| 37 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + version: 3.x |
| 39 | + |
| 40 | + - name: Build |
| 41 | + run: task dist:all |
| 42 | + |
| 43 | + - name: Upload artifacts |
| 44 | + uses: actions/upload-artifact@v2 |
| 45 | + with: |
| 46 | + if-no-files-found: error |
| 47 | + name: ${{ env.ARTIFACT_NAME }} |
| 48 | + path: ${{ env.DIST_DIR }} |
| 49 | + |
| 50 | + create-release: |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + steps: |
| 54 | + - name: Download artifact |
| 55 | + uses: actions/download-artifact@v2 |
| 56 | + with: |
| 57 | + name: ${{ env.ARTIFACT_NAME }} |
| 58 | + path: ${{ env.DIST_DIR }} |
| 59 | + |
| 60 | + - name: Identify Prerelease |
| 61 | + # This is a workaround while waiting for create-release action |
| 62 | + # to implement auto pre-release based on tag |
| 63 | + id: prerelease |
| 64 | + run: | |
| 65 | + wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip |
| 66 | + unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver |
| 67 | + if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "IS_PRE=true" >> $GITHUB_OUTPUT; fi |
| 68 | +
|
| 69 | + - name: Create Github Release and upload artifacts |
| 70 | + uses: ncipollo/release-action@v1 |
| 71 | + with: |
| 72 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 73 | + bodyFile: ${{ env.DIST_DIR }}/CHANGELOG.md |
| 74 | + draft: false |
| 75 | + prerelease: ${{ steps.prerelease.outputs.IS_PRE }} |
| 76 | + # NOTE: "Artifact is a directory" warnings are expected and don't indicate a problem |
| 77 | + # (all the files we need are in the DIST_DIR root) |
| 78 | + artifacts: ${{ env.DIST_DIR }}/* |
0 commit comments