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