Skip to content

Commit

Permalink
ci(release): consolidate GH release logic
Browse files Browse the repository at this point in the history
- use gh cli
- only create release once all assets are ready

Signed-off-by: Vaughn Dice <[email protected]>
  • Loading branch information
vdice committed Dec 20, 2023
1 parent 412b51f commit 9c10079
Showing 1 changed file with 31 additions and 66 deletions.
97 changes: 31 additions & 66 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
id-token: write
# needed to upload artifacts to a GH release
contents: write
outputs:
prerelease: ${{ steps.release-version.outputs.prerelease }}
strategy:
matrix:
config:
Expand Down Expand Up @@ -116,14 +114,6 @@ jobs:
echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml
echo 'rustflags = ["-Ctarget-feature=+fp16"]' >> ${HOME}/.cargo/config.toml
- name: Check if pre-release
id: release-version
shell: bash
run: |
[[ "${{ env.RELEASE_VERSION }}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]] && \
echo "prerelease=false" >> "$GITHUB_OUTPUT" || \
echo "prerelease=true" >> "$GITHUB_OUTPUT"
- name: build release
shell: bash
run: cargo build --release ${{ matrix.config.extraArgs }}
Expand Down Expand Up @@ -166,31 +156,13 @@ jobs:
name: spin
path: _dist/spin-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz

- name: upload binary to Github release
if: startsWith(github.ref, 'refs/tags/v') && runner.os != 'Windows'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/spin-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
tag: ${{ github.ref }}
prerelease: ${{ steps.release-version.outputs.prerelease == 'true' }}

- name: upload binary as GitHub artifact
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: spin
path: _dist/spin-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.zip

- name: upload binary to Github release
if: startsWith(github.ref, 'refs/tags/v') && runner.os == 'Windows'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/spin-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.zip
tag: ${{ github.ref }}
prerelease: ${{ steps.release-version.outputs.prerelease == 'true' }}

- name: Configure AWS Credentials
if: |
runner.os == 'linux' &&
Expand Down Expand Up @@ -240,45 +212,47 @@ jobs:
name: spin
path: checksums-${{ env.RELEASE_VERSION }}.txt

- name: upload checksums to Github release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: checksums-${{ env.RELEASE_VERSION }}.txt
tag: ${{ github.ref }}
prerelease: ${{ needs.build-and-sign.outputs.prerelease == 'true' }}

update-canary:
name: update canary release
create-gh-release:
name: create GitHub release
runs-on: ubuntu-latest
needs: checksums
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Download release assets
- uses: actions/checkout@v3

- name: download release assets
uses: actions/download-artifact@v3
with:
name: spin
path: _dist

- name: Delete canary tag
uses: dev-drprasad/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: canary
delete_release: true
- name: check if pre-release
shell: bash
run: |
if [[ ! "${{ github.ref_name }}" =~ ^v[0-9]+.[0-9]+.[0-9]+$ ]]
then
echo "PRERELEASE=--prerelease" >> "$GITHUB_ENV"
fi
- name: Recreate canary tag and release
uses: ncipollo/[email protected]
with:
tag: canary
allowUpdates: true
prerelease: true
artifacts: "checksums-canary.txt,spin-canary*"
commit: ${{ github.sha }}
body: |
- name: create GitHub release (canary)
if: github.ref == 'refs/heads/main'
run: |
gh release delete canary --cleanup-tag
gh release create canary _dist/* \
--title canary \
--prerelease \
--notes-file - <<- EOF
This is a "canary" release of the most recent commits on our main branch. Canary is **not stable**.
It is only intended for developers wishing to try out the latest features in Spin, some of which may not be fully implemented.
EOF
- name: create GitHub release
if: startsWith(github.ref, 'refs/tags/v')
run: |
gh release create ${{ github.ref_name }} _dist/* \
--title ${{ github.ref_name }} \
--generate-notes ${{ env.PRERELEASE }}
create-go-sdk-tag:
name: create tag sdk/go/v*
Expand Down Expand Up @@ -458,15 +432,6 @@ jobs:
name: spin
path: _dist/spin-${{ env.RELEASE_VERSION }}-static-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz

- name: upload binary to Github release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: _dist/spin-${{ env.RELEASE_VERSION }}-static-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz
tag: ${{ github.ref }}
prerelease: ${{ steps.release-version.outputs.prerelease == 'true' }}

crates:
name: Publish to crates.io
runs-on: ubuntu-latest
Expand Down

0 comments on commit 9c10079

Please sign in to comment.