Nightly Release #124
This file contains 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: Nightly Release | |
# Creates a nightly release and builds and uploads `astria-go` binaries. | |
# NOTE - releases created via automation don't trigger actions that should | |
# trigger on release creation, e.g. build-for-release, so we have to have a | |
# build step in this workflow as well. | |
# see: https://github.com/orgs/community/discussions/25281 | |
on: | |
schedule: | |
# every day at 6AM UTC. late night for America, early morning for Europe | |
- cron: '0 6 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
check-for-changes: | |
runs-on: ubuntu-latest | |
outputs: | |
should_release: ${{ steps.check_changes.outputs.should_release }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # fetch all history for all branches and tags | |
- name: Check for changes | |
id: check_changes | |
run: | | |
git fetch --tags | |
LAST_RELEASE=$(git tag -l --sort=-version:refname | head -n 1) | |
if [ -z "$LAST_RELEASE" ]; then | |
echo "No previous release found. Proceeding with release." | |
echo "should_release=true" >> $GITHUB_OUTPUT | |
else | |
# check for changes in modules/ directory | |
CHANGES=$(git diff --name-only $LAST_RELEASE..HEAD -- modules) | |
if [ -n "$CHANGES" ]; then | |
echo "Changes detected in modules/ since last release. Proceeding with release." | |
echo "should_release=true" >> $GITHUB_OUTPUT | |
else | |
echo "No changes detected in modules/ since last release. Skipping release." | |
echo "should_release=false" >> $GITHUB_OUTPUT | |
fi | |
fi | |
create-nightly-release: | |
needs: check-for-changes | |
if: needs.check-for-changes.outputs.should_release == 'true' | |
runs-on: ubuntu-latest | |
outputs: | |
tag_name: ${{ steps.set_envars.outputs.TAG_NAME }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set envars | |
id: set_envars | |
run: | | |
TODAY=$(date +'%Y-%m-%d') | |
echo "RELEASE_DATE=$TODAY" >> "$GITHUB_OUTPUT" | |
echo "TAG_NAME=nightly-$TODAY" >> "$GITHUB_OUTPUT" | |
- name: Create Nightly Release | |
id: create_release | |
uses: softprops/action-gh-release@v2 | |
with: | |
name: "Nightly Release ${{ steps.set_envars.outputs.RELEASE_DATE }}" | |
body: "${{ steps.set_envars.outputs.RELEASE_DATE }} nightly release of `astria-go`" | |
tag_name: ${{ steps.set_envars.outputs.TAG_NAME }} | |
prerelease: true | |
draft: false | |
generate_release_notes: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
build-and-upload: | |
needs: [check-for-changes, create-nightly-release] | |
if: needs.check-for-changes.outputs.should_release == 'true' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [ linux, darwin ] | |
goarch: [ amd64, arm64 ] | |
exclude: | |
- goarch: "arm64" | |
goos: "linux" | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Build and Upload Nightly Release | |
uses: wangyoucao577/go-release-action@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
goos: ${{ matrix.goos }} | |
goarch: ${{ matrix.goarch }} | |
ldflags: > | |
-s -w -X github.com/astriaorg/astria-cli-go/modules/cli/cmd.version=${{ needs.create-nightly-release.outputs.tag_name }} | |
project_path: "./modules/cli" | |
binary_name: "astria-go" | |
release_tag: ${{ needs.create-nightly-release.outputs.tag_name }} |