Skip to content

Publish

Publish #163

Workflow file for this run

name: Publish
on:
workflow_run:
workflows: CI
branches: main
types: completed
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
publish:
if: github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- name: Checkout repository
uses: actions/checkout@v4.1.7
with:
show-progress: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2.0.1
with:
bun-version: latest
- name: Install node dependencies
run: bun install --frozen-lockfile
- name: Create release PR or publish
uses: changesets/action@v1.4.7
id: changesets
with:
title: 'build: bump version packages'
commit: 'build: bump version packages'
publish: bun release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
compile:
runs-on: ${{ matrix.runs-on }}-latest
strategy:
matrix:
runs-on: [ubuntu, macos, windows]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Setup Bun
uses: oven-sh/setup-bun@v2.0.1
with:
bun-version: latest
- name: Install node dependencies
run: bun install --frozen-lockfile
- name: Compile
run: bun compile
- name: Test on Linux
if: matrix.runs-on != 'windows'
run: |
bin/sgqr \
--number +6591234567 \
--amount 420.69 \
--type image/svg+xml | cat | grep '<svg.*xmlns="http://www.w3.org/2000/svg"'
- name: Test on Windows
if: matrix.runs-on == 'windows'
run: |
bin/sgqr `
--number +6591234567 `
--amount 420.69 `
--type image/svg+xml | Select-String "<svg.*xmlns=`"http://www.w3.org/2000/svg`""
- name: Compress binary on Linux
if: matrix.runs-on != 'windows'
run: zip -rj sgqr-${{ matrix.runs-on }}.zip bin/sgqr
- name: Compress binary on Windows
if: matrix.runs-on == 'windows'
run: Compress-Archive -Path bin/sgqr.exe -DestinationPath sgqr-${{ matrix.runs-on }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4.3.6
with:
name: artifact-${{ matrix.runs-on }}
path: sgqr-${{ matrix.runs-on }}.zip
release:
needs: [publish, compile]
if: needs.publish.outputs.published == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download Linux artifact
uses: actions/download-artifact@v4.1.8
with:
pattern: artifact-*
merge-multiple: true
- name: Rename artifacts
run: |
mv sgqr-ubuntu.zip sgqr-linux.zip
mv sgqr-macos.zip sgqr-linux-arm64.zip
- name: Release
run: gh release upload $(gh release view --json tagName -q .tagName) sgqr-*.zip
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}