Skip to content

Commit

Permalink
reordering release jobs to avoid publishing new github release
Browse files Browse the repository at this point in the history
  • Loading branch information
enekofb committed Aug 30, 2023
1 parent 2687831 commit 1d18b77
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 59 deletions.
114 changes: 55 additions & 59 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,60 +32,8 @@ jobs:
git tag -a ${{ steps.release-version.outputs.version }} -m ${{ steps.release-version.outputs.version }}
git push origin tag ${{ steps.release-version.outputs.version }}
goreleaser:
runs-on: ubuntu-latest
needs: tag-release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Unshallow
run: |
git fetch --prune --unshallow
git fetch --tags -f
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.20.X
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.X
- name: Set env var
run: |
echo "BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo "GORELEASER_PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))" >> $GITHUB_ENV
echo "GORELEASER_CURRENT_TAG=${{ needs.tag-release.outputs.version }}" >> $GITHUB_ENV
echo "DEV_BUCKET_CONTAINER_IMAGE=$(make echo-dev-bucket-container)" >> $GITHUB_ENV
echo "FLUX_VERSION=$(make echo-flux-version)" >> $GITHUB_ENV
echo "CHART_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)" >> $GITHUB_ENV
- name: "Make All"
run: make all
- name: Check Git State
run: git diff --no-ext-diff --exit-code
- name: Include brew publishing
run: cat .goreleaser.brew.yml >> .goreleaser.yml
if: ${{ !contains(github.event.pull_request.head.ref, '-') }}
- name: Store changelog
run: |
cat > ${{ runner.temp }}/changelog.md <<'END_OF_CHANGELOG'
${{ github.event.pull_request.body }}
END_OF_CHANGELOG
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist --skip-validate --release-notes=${{ runner.temp }}/changelog.md
env:
GITHUB_TOKEN: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
BOT_TOKEN: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
BRANCH: ${{ env.BRANCH }}
GORELEASER_PREVIOUS_TAG: ${{ env.GORELEASER_PREVIOUS_TAG }}
GORELEASER_CURRENT_TAG: ${{ env.GORELEASER_CURRENT_TAG }}

publish_npm_package:
needs: goreleaser
needs: tag-release
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -102,9 +50,7 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-push-image:
needs:
- goreleaser
- tag-release
needs: tag-release
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -156,13 +102,63 @@ jobs:
LDFLAGS=${{ env.LDFLAGS }}
GIT_COMMIT=${{ github.sha }}
merge-pr:
goreleaser:
runs-on: ubuntu-latest
needs:
- tag-release
- goreleaser
- publish_npm_package
- build-and-push-image
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Unshallow
run: |
git fetch --prune --unshallow
git fetch --tags -f
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.20.X
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 16.X
- name: Set env var
run: |
echo "BRANCH=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
echo "GORELEASER_PREVIOUS_TAG=$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))" >> $GITHUB_ENV
echo "GORELEASER_CURRENT_TAG=${{ needs.tag-release.outputs.version }}" >> $GITHUB_ENV
echo "DEV_BUCKET_CONTAINER_IMAGE=$(make echo-dev-bucket-container)" >> $GITHUB_ENV
echo "FLUX_VERSION=$(make echo-flux-version)" >> $GITHUB_ENV
echo "CHART_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)" >> $GITHUB_ENV
- name: "Make All"
run: make all
- name: Check Git State
run: git diff --no-ext-diff --exit-code
- name: Include brew publishing
run: cat .goreleaser.brew.yml >> .goreleaser.yml
if: ${{ !contains(github.event.pull_request.head.ref, '-') }}
- name: Store changelog
run: |
cat > ${{ runner.temp }}/changelog.md <<'END_OF_CHANGELOG'
${{ github.event.pull_request.body }}
END_OF_CHANGELOG
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist --skip-validate --release-notes=${{ runner.temp }}/changelog.md
env:
GITHUB_TOKEN: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
BOT_TOKEN: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
BRANCH: ${{ env.BRANCH }}
GORELEASER_PREVIOUS_TAG: ${{ env.GORELEASER_PREVIOUS_TAG }}
GORELEASER_CURRENT_TAG: ${{ env.GORELEASER_CURRENT_TAG }}

merge-pr:
runs-on: ubuntu-latest
needs: goreleaser
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
22 changes: 22 additions & 0 deletions doc/adr/0016-release-ordering.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 0016. Change release ordering to only publish GitHub release when artifacts are available

## Status

Proposed

## Context

Current release workflow ordering published a GitHub release before the artifacts are available. That flags users
that they can use the new release however if they follow the signal of the GitHub release, they will fail the release
as the container image won't be available at that time.

## Decision

Change release ordering to ensure that we only publish the GitHub release after the container image is published.


## Consequences

Weave Gitops users that upgrades after a GitHub release has been publishes will not fail the upgrade. There is a consideration/limitation to this point: the helm chart is published in another workflow that only
is triggered once the PR is merged. Therefore, there is still a gap between when the GitHub Release is published and all the artifacts are available.
This gap in terms of time is small to compare the one that this ADR addresses, but it also needs to be addressed .

0 comments on commit 1d18b77

Please sign in to comment.