release #36
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: release | |
on: | |
workflow_dispatch: | |
inputs: | |
commit: | |
description: "commit SHA to make release from" | |
required: true | |
default: main | |
version: | |
description: "release version, also creates a tag e.g. (0.1.0)" | |
required: true | |
permissions: | |
actions: read | |
checks: none | |
contents: write | |
deployments: none | |
issues: none | |
packages: write | |
pull-requests: none | |
repository-projects: none | |
security-events: none | |
statuses: none | |
jobs: | |
release: | |
strategy: | |
matrix: | |
os: ["ubuntu-22.04", "depot-ubuntu-22.04-arm"] | |
include: | |
- os: ubuntu-22.04 | |
arch: linux/amd64 | |
sha: f02ffb48eae99d6c884c9aa0378070cc716d028f58e87deec5ae00a41b706fe8 | |
arch-suffix: amd64 | |
- os: depot-ubuntu-22.04-arm | |
arch: linux/arm64 | |
sha: d9267eb176190b96dcfa29ba4c4c685a26a4a1aca1d7f15deb31ec33ed63de15 | |
arch-suffix: arm64 | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Docker Login | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.commit }} | |
- name: Validate version | |
run: ./scripts/semver.sh ${{ github.event.inputs.version }} | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: "~1.23" | |
- name: Go Cache Paths | |
id: go-cache-paths | |
run: | | |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | |
- name: Go Mod Cache | |
uses: actions/cache@v3 | |
with: | |
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }} | |
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }} | |
- name: Setup Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Coder CI" | |
- name: Build Image | |
run: make -j ARCH=${{ matrix.arch }} SYSBOX_SHA=${{ matrix.sha }} build/image/envbox | |
- name: Tag Image | |
run: docker tag envbox ghcr.io/coder/envbox:${{ github.event.inputs.version }}-${{ matrix.arch-suffix }} | |
- name: Push Image | |
run: docker push ghcr.io/coder/envbox:${{ github.event.inputs.version }}-${{ matrix.arch-suffix }} | |
manifest: | |
runs-on: ubuntu-22.04 | |
needs: release | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.commit }} | |
- name: Docker Login | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Manifest | |
run: | | |
docker manifest create ghcr.io/coder/envbox:${{ github.event.inputs.version }} \ | |
--amend ghcr.io/coder/envbox:${{ github.event.inputs.version }}-amd64 \ | |
--amend ghcr.io/coder/envbox:${{ github.event.inputs.version }}-arm64 | |
- name: Push Manifest | |
run: | | |
docker manifest push ghcr.io/coder/envbox:${{ github.event.inputs.version }} | |
tag: | |
runs-on: ubuntu-22.04 | |
needs: manifest | |
env: | |
GH_TOKEN: ${{ github.token }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.commit }} | |
- name: Setup Git | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Coder CI" | |
- name: Tag and Push Commit | |
run: | | |
git tag -a ${{ github.event.inputs.version }} -m ${{ github.event.inputs.version }} | |
git push --tags | |
- name: Create Release | |
run: | | |
version=${{ github.event.inputs.version }} | |
if [[ $version == *-rc* ]]; then | |
gh release create "$version" -t "$version" --generate-notes --prerelease --latest=false --verify-tag | |
else | |
gh release create $version -t $version --generate-notes --verify-tag | |
fi |