|
| 1 | +name: scallop-release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: [scallop-*] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + release: ${{ steps.release.outputs.release }} |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v6 |
| 16 | + |
| 17 | + - name: Get the release name |
| 18 | + id: release |
| 19 | + run: | |
| 20 | + name=$(sed -rn "/^PACKAGE_NAME=/ s/^.*='(.*)'/\1/p" configure) |
| 21 | + version=$(sed -rn "/^PACKAGE_VERSION=/ s/^.*='(.*)'/\1/p" configure) |
| 22 | + release=${name}-${version} |
| 23 | +
|
| 24 | + # verify tag name matches configure script |
| 25 | + if ! [[ ${{ github.ref_name }} =~ scallop-* ]]; then |
| 26 | + if ! [[ ${{ github.ref_name }} == ${release} ]]; then |
| 27 | + echo "tag name ${{ github.ref_name }} doesn't match package: ${release}" |
| 28 | + exit 1 |
| 29 | + fi |
| 30 | + fi |
| 31 | +
|
| 32 | + echo "release=${release}" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + source: |
| 35 | + needs: release |
| 36 | + runs-on: ubuntu-latest |
| 37 | + env: |
| 38 | + RELEASE: ${{ needs.release.outputs.release }} |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout code |
| 42 | + uses: actions/checkout@v6 |
| 43 | + with: |
| 44 | + path: bash |
| 45 | + |
| 46 | + - name: Create archive |
| 47 | + run: | |
| 48 | + # remove unused files |
| 49 | + rm -r bash/{doc,examples,tests,po} |
| 50 | +
|
| 51 | + # create tarball |
| 52 | + mkdir ${RELEASE} |
| 53 | + cp -av bash/* ${RELEASE} |
| 54 | + tar -cv -I "xz -9 -T0" -f ${RELEASE}.tar.xz ${RELEASE} |
| 55 | +
|
| 56 | + - name: Upload artifact |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: source |
| 60 | + path: ./*.tar.xz |
| 61 | + if-no-files-found: error |
| 62 | + retention-days: 3 |
| 63 | + |
| 64 | + publish: |
| 65 | + if: startsWith(github.ref, 'refs/tags/') |
| 66 | + needs: source |
| 67 | + runs-on: ubuntu-latest |
| 68 | + permissions: |
| 69 | + contents: write |
| 70 | + |
| 71 | + steps: |
| 72 | + - name: Download artifacts |
| 73 | + uses: actions/download-artifact@v4 |
| 74 | + with: |
| 75 | + path: artifacts |
| 76 | + merge-multiple: true |
| 77 | + |
| 78 | + - name: Create GitHub release |
| 79 | + uses: softprops/action-gh-release@v2 |
| 80 | + with: |
| 81 | + files: artifacts/*.tar.xz |
| 82 | + fail_on_unmatched_files: true |
0 commit comments