|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + branch: |
| 7 | + description: 'Branch to release from' |
| 8 | + required: true |
| 9 | + default: 'beta' |
| 10 | + type: choice |
| 11 | + options: |
| 12 | + - beta |
| 13 | + - prod |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: write |
| 17 | + |
| 18 | +jobs: |
| 19 | + get-versions: |
| 20 | + uses: ./.github/workflows/versions.yml |
| 21 | + |
| 22 | + build-and-release: |
| 23 | + name: Build Release Assets |
| 24 | + needs: get-versions |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + os: [ubuntu-latest, windows-latest, macos-latest, macos-12, ubuntu-20.04] |
| 28 | + arch: [x64, arm64] |
| 29 | + exclude: |
| 30 | + - os: windows-latest |
| 31 | + arch: arm64 |
| 32 | + runs-on: ${{ matrix.os }} |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Checkout repository |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Setup Node.js |
| 39 | + uses: actions/setup-node@v4 |
| 40 | + with: |
| 41 | + node-version: ${{ needs.get-versions.outputs.node-version }} |
| 42 | + cache: 'npm' |
| 43 | + |
| 44 | + # - name: Setup Go |
| 45 | + # uses: actions/setup-go@v5 |
| 46 | + # with: |
| 47 | + # go-version: ${{ needs.get-versions.outputs.go-version }} |
| 48 | + |
| 49 | + - name: Install Node.js dependencies |
| 50 | + run: npm ci |
| 51 | + |
| 52 | + - name: Build Node.js application |
| 53 | + shell: bash |
| 54 | + run: | |
| 55 | + if [ "${{ github.event.inputs.branch }}" == "beta" ]; then |
| 56 | + npm run bundle:beta |
| 57 | + else |
| 58 | + npm run bundle:prod |
| 59 | + fi |
| 60 | +
|
| 61 | + # - name: Build Go application |
| 62 | + # run: npm run build:go:prod |
| 63 | + |
| 64 | + - name: Read version from package.json |
| 65 | + id: get-version |
| 66 | + run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT |
| 67 | + |
| 68 | + - name: Set Release Asset Name |
| 69 | + id: set-asset-name |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + APP_NAME='${{ needs.get-versions.outputs.app-name }}' |
| 73 | + VERSION=${{ steps.get-version.outputs.version }} |
| 74 | + OS=${{ matrix.os }} |
| 75 | + ARCH=${{ matrix.arch }} |
| 76 | + BRANCH=${{ github.event.inputs.branch }} |
| 77 | +
|
| 78 | + if [ "$BRANCH" = "beta" ]; then |
| 79 | + ASSET_NAME="${APP_NAME}-beta-${VERSION}-${OS}-${ARCH}.zip" |
| 80 | + else |
| 81 | + ASSET_NAME="${APP_NAME}-${VERSION}-${OS}-${ARCH}.zip" |
| 82 | + fi |
| 83 | +
|
| 84 | + echo "ASSET_NAME=$ASSET_NAME" >> $GITHUB_OUTPUT |
| 85 | + echo "ASSET_PATH=./$ASSET_NAME" >> $GITHUB_OUTPUT |
| 86 | + echo "ASSET_PATH=./$ASSET_NAME" >> $GITHUB_OUTPUT |
| 87 | +
|
| 88 | + - name: Create Zip Archive of the bundle |
| 89 | + shell: bash |
| 90 | + run: | |
| 91 | + zip -r ${{ steps.set-asset-name.outputs.ASSET_NAME }} bundle/production |
| 92 | +
|
| 93 | + - name: Create GitHub Release |
| 94 | + uses: softprops/action-gh-release@v2 |
| 95 | + with: |
| 96 | + tag_name: v${{ steps.get-version.outputs.version }} |
| 97 | + name: Release v${{ steps.get-version.outputs.version }}${{ github.event.inputs.branch == 'beta' && ' (Beta)' || '' }} |
| 98 | + prerelease: ${{ github.event.inputs.branch == 'beta' }} |
| 99 | + files: ${{ steps.set-asset-name.outputs.ASSET_PATH }} |
| 100 | + fail_on_unmatched_files: true |
| 101 | + body: 'Release based on commit: ${{ github.sha }}' |
| 102 | + env: |
| 103 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments