|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v[0-9]*.[0-9]*.[0-9]*' # matches "v<number...>.<number...>.<number>..." |
| 7 | + |
| 8 | +jobs: |
| 9 | + # Check prerequisites for the workflow |
| 10 | + prereqs: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + tag_version: ${{ steps.tag.outputs.version }} # The version number (without preceding "v"), e.g. 1.0.0 |
| 14 | + steps: |
| 15 | + - name: Determine tag to build |
| 16 | + run: | |
| 17 | + echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT |
| 18 | + id: tag |
| 19 | + |
| 20 | + package: |
| 21 | + needs: prereqs |
| 22 | + name: ${{matrix.jobs.jobname}} |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + jobs: |
| 27 | + - jobname: Create MacOS .pkg (x86_64) |
| 28 | + goarch: amd64 |
| 29 | + pool: macos-latest |
| 30 | + artifact: _dist/*.pkg |
| 31 | + - jobname: Create MacOS .pkg (ARM64) |
| 32 | + goarch: arm64 |
| 33 | + pool: macos-latest |
| 34 | + artifact: _dist/*.pkg |
| 35 | + - jobname: Create binary Debian package (x86_64) |
| 36 | + goarch: amd64 |
| 37 | + pool: ubuntu-latest |
| 38 | + artifact: _dist/*.deb |
| 39 | + env: |
| 40 | + GOARCH: ${{matrix.jobs.goarch}} |
| 41 | + runs-on: ${{matrix.jobs.pool}} |
| 42 | + steps: |
| 43 | + - name: Setup Go |
| 44 | + uses: actions/setup-go@v3 |
| 45 | + with: |
| 46 | + go-version: '1.19.0' |
| 47 | + - name: Clone repository |
| 48 | + uses: actions/checkout@v3 |
| 49 | + - name: Build the release artifact |
| 50 | + run: make package VERSION=${{ needs.prereqs.outputs.tag_version }} |
| 51 | + - name: Get the release artifact |
| 52 | + shell: bash |
| 53 | + run: | |
| 54 | + artifacts=(${{matrix.jobs.artifact}}) |
| 55 | +
|
| 56 | + # Get path to, and name of, artifact |
| 57 | + artifactPath="${artifacts[0]}" |
| 58 | + artifactName=$(basename "$artifactPath") |
| 59 | +
|
| 60 | + # Export variables to environment |
| 61 | + echo "artifactPath=$artifactPath" >> $GITHUB_ENV |
| 62 | + echo "artifactName=$artifactName" >> $GITHUB_ENV |
| 63 | + - name: Upload release artifact |
| 64 | + uses: actions/upload-artifact@v3 |
| 65 | + with: |
| 66 | + name: ${{env.artifactName}} |
| 67 | + path: ${{github.workspace}}/${{env.artifactPath}} |
| 68 | + if-no-files-found: error |
0 commit comments