Release #327
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: | |
version: | |
description: "Version: Tag, build and release. (e.g. 1.2.3 or 1.2.4-rc)" | |
required: true | |
force: | |
description: "Enter 'force-reuse-tag', if you want to change an existing git tag. CAUTION!" | |
required: false | |
default: "" | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# Clone all history to ensure goreleaser can create proper changelog. | |
fetch-depth: 0 | |
- name: Set Version | |
run: | | |
VERSION="${{ github.event.inputs.version }}" | |
FORCE="${{ github.event.inputs.force }}" | |
echo "Inputs: version: $VERSION, force: $FORCE" | |
git fetch origin --tags | |
[[ "$FORCE" == "force-reuse-tag" ]] && GIT_ARG="--force" || GIT_ARG="" | |
source release/source.sh | |
echo "GORELEASER_PREVIOUS_TAG=$PROTOCURL_RELEASED_VVERSION" >> $GITHUB_ENV | |
set -x | |
git tag $GIT_ARG "v${{ github.event.inputs.version }}" | |
git push --tags $GIT_ARG | |
set +x | |
source release/source.sh | |
- name: Install Go and Goreleaser | |
run: | | |
sudo apt-get -q update | |
sudo apt-get -q install -y jq zip unzip curl | |
source release/source.sh | |
sudo ./release/20-install-go.sh "$GO_DOWNLOAD_URL" this-is-not-my-development-computer | |
wget -q "$GORELEASER_DOWNLOAD_URL" | |
sudo dpkg -i goreleaser*.deb | |
rm -f *.deb *.gz | |
- name: Delete GitHub Release (if force) | |
if: github.event.inputs.force == 'force-reuse-tag' | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
echo "Deleting existing release, if it exists" | |
gh release delete -y "v${{ github.event.inputs.version }}" || true | |
- name: Build Archive | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
export PATH=$PATH:/usr/local/go/bin | |
export GORELEASER_CURRENT_TAG="v${{ github.event.inputs.version }}" | |
export GORELEASER_PREVIOUS_TAG="${{ env.GORELEASER_PREVIOUS_TAG }}" | |
./release/30-build-go-archive.sh | |
- name: DockerHub Login | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Setup QEMU for docker buildx | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Check DockerHub image does not already exist (except if force or snapshot) | |
run: | | |
source release/source.sh | |
if [[ "${{ github.event.inputs.force }}" == "force-reuse-tag" || "$SNAPSHOT" == "true" ]]; then | |
echo "No check needed." | |
exit 0 | |
fi | |
URL="https://hub.docker.com/v2/repositories/qaware/protocurl/tags/${{ github.event.inputs.version }}" | |
JSON="$(curl -s "$URL")" | |
if [[ "$JSON" == *"\"creator\""* ]]; then | |
echo "ERROR: qaware/protocurl:${{ github.event.inputs.version }} already exists on DockerHub!" | |
echo "If you know what you are doing and this is intentional, then you may set force -> 'force-reuse-tag'." | |
exit 1 | |
fi | |
echo "OK. Building and pushing the docker image would not overwrite an existing tag." | |
- name: Prepare and Decide if qaware/protocurl:latest should be published | |
run: | | |
./release/40-generate-Dockerfile.sh | |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable | |
echo "publish_latest=false" >> $GITHUB_ENV | |
source release/source.sh | |
if [[ "$SNAPSHOT" == "false" ]]; then | |
TAG=qaware/protocurl:latest | |
echo "$TAG will be set" | |
echo "publish_latest=true" >> $GITHUB_ENV | |
fi | |
- name: DockerHub Build and Release (with latest) | |
uses: docker/build-push-action@v5 | |
if: env.publish_latest == 'true' | |
with: | |
platforms: linux/amd64,linux/arm64 | |
build-args: VERSION=${{ github.event.inputs.version }} | |
tags: qaware/protocurl:${{ github.event.inputs.version }}, qaware/protocurl:latest | |
file: release/generated.Dockerfile | |
push: true | |
context: . | |
- name: DockerHub Build and Release (without latest) | |
uses: docker/build-push-action@v5 | |
if: env.publish_latest == 'false' | |
with: | |
platforms: linux/amd64,linux/arm64 | |
build-args: VERSION=${{ github.event.inputs.version }} | |
tags: qaware/protocurl:${{ github.event.inputs.version }} | |
file: release/generated.Dockerfile | |
push: true | |
context: . | |
- name: Test Release | |
run: | | |
git fetch --tags origin | |
export PROTOCURL_RELEASE_VERSION="${{ github.event.inputs.version }}" | |
./test/suite/test.sh "$PWD" | |
- name: Security Scan | |
uses: crazy-max/ghaction-container-scan@v3 | |
continue-on-error: true | |
with: | |
image: qaware/protocurl:${{ github.event.inputs.version }} | |
severity_threshold: MEDIUM | |
dockerfile: release/generated.Dockerfile | |
post-release-test-windows: | |
runs-on: windows-latest | |
needs: [ release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Choco Install curl | |
uses: crazy-max/ghaction-chocolatey@v3 | |
with: | |
args: install curl -y --limit-output | |
- name: Download release | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
$ErrorActionPreference = "Stop" | |
Write-Output "Downloading release from Github ..." | |
gh release download v${{ github.event.inputs.version }} --pattern '*windows*amd64*.zip' | |
Write-Output "working dir after download" | |
ls | |
Write-Output "Attempting to extract" | |
Expand-Archive *.zip -DestinationPath my-protocurl | |
Write-Output "After extract" | |
ls my-protocurl | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "17.7.2" | |
- name: Start test server | |
run: | | |
$ErrorActionPreference = "Stop" | |
cd test | |
& ".\servers\native-start-server.ps1" | |
- name: Test extracted release and global installation | |
run: | | |
$ErrorActionPreference = "Stop" | |
& ".\test\suite\native-tests.ps1" "my-protocurl" ".exe" "localDirTests" | |
post-release-test-mac: | |
runs-on: macos-latest | |
needs: [ release ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup | |
run: "brew install powershell" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "17.7.2" | |
- name: Download release | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: | | |
echo "Downloading release from Github ..." | |
ARCH="$(uname -m | | |
sed "s/x86_64/amd64/g" | | |
sed "s/x86_32/386/g" | | |
sed "s/aarch_64/arm64/g")" | |
echo "Arch: $ARCH" | |
gh release download v${{ github.event.inputs.version }} --pattern "*darwin*$ARCH*.zip" | |
echo "Working dir after Download" | |
ls | |
echo "Attempting to extract" | |
unzip *.zip -d my-protocurl | |
echo "After extract" | |
ls my-protocurl | |
- name: Start test server | |
run: | | |
cd test | |
pwsh servers/native-start-server.ps1 | |
- name: Test extracted release and global installation | |
run: | | |
pwsh test/suite/native-tests.ps1 "my-protocurl" "" "localDirTests" | |
post-release-test-linux: | |
runs-on: ubuntu-latest | |
needs: [ release ] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "17.7.2" | |
- name: Start test server | |
run: | | |
cd test | |
pwsh servers/native-start-server.ps1 | |
- name: "Run tests for linux package formats: deb, apk" | |
run: | | |
ARCH="$(uname -m | | |
sed "s/x86_64/amd64/g" | | |
sed "s/x86_32/386/g" | | |
sed "s/aarch_64/arm64/g")" | |
URL_NO_EXT="https://github.com/qaware/protocurl/releases/download/v${{github.event.inputs.version}}/protocurl_${{github.event.inputs.version}}_linux_${ARCH}" | |
docker run --network host -v $PWD/test:/home/test alpine:latest sh -c \ | |
"cd home; apk add --no-cache bash && bash ./test/suite/linux/install-test-remove.sh alpine .apk $URL_NO_EXT" | |
docker run --network host -v $PWD/test:/home/test debian:11-slim bash -c \ | |
"cd home; ./test/suite/linux/install-test-remove.sh debian .deb $URL_NO_EXT" | |