Skip to content

Add release automation on tag push #60

Add release automation on tag push

Add release automation on tag push #60

Workflow file for this run

name: Releases workflow
on:
create:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
env:
GO_VERSION: '1.20.6'
permissions:
contents: write
deployments: write
jobs:
set-env-vars:
runs-on: ubuntu-20.04
steps:
- name: Export vars
id: step
run: |
export raw_ref=${{ github.ref }}
export release_tag=${GITHUB_REF#refs/*/}
echo "release_tag=$release_tag" >> $GITHUB_ENV
export release_version=${release_tag/v/} # Remove v from tag name
echo "release_version=$release_version" >> $GITHUB_ENV
echo "branch_name=release/${release_version%.*}" >> $GITHUB_ENV
outputs:
release_tag: ${{ env.release_tag }}
release_version: ${{ env.release_version }}
branch_name: ${{ env.branch_name }}
# TODO: Any way we can just call build.yml?
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- run: make
- run: make test
integration:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
containerd: ["1.6.19", "1.7.0"]
env:
DOCKER_BUILD_ARGS: "CONTAINERD_VERSION=${{ matrix.containerd }}"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.20.6'
- run: make integration
generate-artifacts:
needs: set-env-vars
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Temp REMOVE BEFORE MERGING TO MAIN
run: |
touch THIRD_PARTY_LICENSES
- name: Setup and export variables
id: vars
run: |
mkdir release
echo "dynamic_binary_name=soci-snapshotter-${{ needs.set-env-vars.outputs.release_version }}-linux-amd64.tar.gz" >> $GITHUB_ENV
echo "static_binary_name=soci-snapshotter-${{ needs.set-env-vars.outputs.release_version }}-linux-amd64-static.tar.gz" >> $GITHUB_ENV
- name: Create dynamic binary
run: |
make build
cp NOTICE.md THIRD_PARTY_LICENSES out/
cd out/
tar -czvf ../release/${{ env.dynamic_binary_name }} *
cd ../
rm -rf out/
- name: Create static binary
run: |
make STATIC=1 build
cp NOTICE.md THIRD_PARTY_LICENSES out/
cd out/
tar -czvf ../release/${{ env.static_binary_name }} *
cd ../
rm -rf out/
- name: Create sha256 sums
run: |
cd release/
sha256sum ${{ env.dynamic_binary_name }} > ${{ env.static_binary_name }}.sha256sum
sha256sum ${{ env.dynamic_binary_name }} > ${{ env.static_binary_name }}.sha256sum
- name: Upload artifacts
uses: actions/upload-artifact
with:
name: artifacts
path: release/
if-no-files-found: error
outputs:
dynamic_binary_name: ${{ env.dynamic_binary_name }}
static_binary_name: ${{ env.static_binary_name }}
create-release:
needs: [set-env-vars, generate-artifacts]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: artifacts
- uses: "marvinpinto/[email protected]"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
draft: true
prerelease: false
automatic_release_tag: ${{ needs.set-env-vars.outputs.release_tag }}
files: |
${{ needs.generate-artifacts.outputs.dynamic_binary_name }}
${{ needs.generate-artifacts.outputs.dynamic_binary_name }}.sha256sum
${{ needs.generate-artifacts.outputs.static_binary_name }}
${{ needs.generate-artifacts.outputs.static_binary_name }}.sha256sum