|
| 1 | +# NOTE: This name appears in GitHub's Checks API and in workflow's status badge. |
| 2 | +name: release |
| 3 | + |
| 4 | +# Trigger the workflow when: |
| 5 | +on: |
| 6 | + # A push occurs to one of the matched tags. |
| 7 | + push: |
| 8 | + tags: |
| 9 | + # Pattern that roughly matches Oasis Core's version tags. |
| 10 | + # For more details on GitHub Actions' pattern match syntax, see: |
| 11 | + # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags. |
| 12 | + - 'v[0-9]+.[0-9]+*' |
| 13 | + |
| 14 | +jobs: |
| 15 | + release: |
| 16 | + # NOTE: This name appears in GitHub's Checks API. |
| 17 | + name: prepare-release |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + submodules: true |
| 26 | + - name: Set up Node.js 20 |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: '20.x' |
| 30 | + cache: yarn |
| 31 | + - name: Install dependencies |
| 32 | + run: yarn install --frozen-lockfile |
| 33 | + - name: Build app |
| 34 | + run: yarn build |
| 35 | + - name: Set workflow variables |
| 36 | + # Id is needed to access output in a next step. |
| 37 | + id: vars |
| 38 | + env: |
| 39 | + # There's no support for escaping this for use in a shell command. |
| 40 | + # GitHub's recommendation is to pass it through the environment. |
| 41 | + # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable |
| 42 | + REF_NAME: ${{ github.ref_name }} |
| 43 | + # We want to show version without the leading 'v' |
| 44 | + # and use short SHA of the commit for file name. |
| 45 | + run: | |
| 46 | + echo "VERSION=$(echo "$REF_NAME" | sed 's/^v//')" >> "$GITHUB_OUTPUT" |
| 47 | + - name: Create zip file |
| 48 | + env: |
| 49 | + # Need to escape again |
| 50 | + VERSION: ${{ steps.vars.outputs.VERSION }} |
| 51 | + run: | |
| 52 | + cd dist/ |
| 53 | + zip -r "../rofl-app-$VERSION.zip" . |
| 54 | + - name: Parse CHANGELOG.md file and extract changes for the given version |
| 55 | + uses: buberdds/extract-changelog-action@v1 |
| 56 | + id: changelog |
| 57 | + with: |
| 58 | + version: ${{ steps.vars.outputs.VERSION }} |
| 59 | + - name: Release |
| 60 | + uses: softprops/action-gh-release@v2 |
| 61 | + with: |
| 62 | + files: | |
| 63 | + rofl-app-${{ steps.vars.outputs.VERSION }}.zip |
| 64 | + name: ROFL App ${{ steps.vars.outputs.VERSION }} |
| 65 | + body: ${{ steps.changelog.outputs.content }} |
| 66 | + env: |
| 67 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments