Fix rclone R2 config and simplify release workflow (#1749) #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| name: release | |
| on: | |
| push: | |
| tags: | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| workflow_dispatch: | |
| env: | |
| PKG_CACHE_PATH: .pkg | |
| jobs: | |
| release: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set version from tag | |
| if: github.ref_type == 'tag' | |
| run: | | |
| sed -i "s/0.0.0/${GITHUB_REF_NAME}/g" package.json src/index.ts | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: '24' | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - uses: actions/cache@v5.0.3 | |
| with: | |
| path: ${{ env.PKG_CACHE_PATH }} | |
| key: pkg-cache | |
| - run: npm ci | |
| - run: npm run build | |
| - run: npm run esbuild | |
| - run: npm run pkg-all | |
| - name: Install rclone | |
| run: sudo apt-get update && sudo apt-get install -y rclone | |
| - name: Download existing ppa from R2 | |
| run: rclone copy r2:${R2_BUCKET}/ ppa/ | |
| env: | |
| R2_BUCKET: ${{ secrets.R2_BUCKET }} | |
| RCLONE_CONFIG_R2_TYPE: s3 | |
| RCLONE_CONFIG_R2_PROVIDER: Cloudflare | |
| RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} | |
| RCLONE_CONFIG_R2_NO_CHECK_BUCKET: true | |
| - name: Import GPG key and preset passphrase | |
| run: | | |
| echo "${GPG_PRIVATE_KEY}" | gpg --batch --import | |
| echo "allow-preset-passphrase" >> ~/.gnupg/gpg-agent.conf | |
| gpgconf --kill gpg-agent | |
| gpgconf --launch gpg-agent | |
| for keygrip in $(gpg --list-secret-keys --with-keygrip --with-colons madsjon@gmail.com | awk -F: '/grp/{print $10}'); do | |
| /usr/lib/gnupg/gpg-preset-passphrase --preset --passphrase "${GPG_PASSPHRASE}" "$keygrip" | |
| done | |
| env: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
| - name: Build .deb and sign | |
| run: ./publish-deb | |
| - name: Publish to npm | |
| if: github.ref_type == 'tag' | |
| run: npm publish --provenance | |
| - name: Create GitHub Release | |
| if: github.ref_type == 'tag' | |
| run: gh release create "${GITHUB_REF_NAME}" bin/*.gz --generate-notes | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload ppa to Cloudflare R2 | |
| if: github.ref_type == 'tag' | |
| run: rclone copy ppa/ r2:${R2_BUCKET}/ | |
| env: | |
| R2_BUCKET: ${{ secrets.R2_BUCKET }} | |
| RCLONE_CONFIG_R2_TYPE: s3 | |
| RCLONE_CONFIG_R2_PROVIDER: Cloudflare | |
| RCLONE_CONFIG_R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| RCLONE_CONFIG_R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| RCLONE_CONFIG_R2_ENDPOINT: ${{ secrets.R2_ENDPOINT }} | |
| RCLONE_CONFIG_R2_NO_CHECK_BUCKET: true |