Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(release): consolidate GH release logic #2185

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+100 for using gh cli instead of third party actions for creating canary release

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