Skip to content

Tag release

Tag release #140

Workflow file for this run

name: Tag release
on: workflow_dispatch
env:
NODE_ENV: production
jobs:
release:
name: Tag release
runs-on: ubuntu-22.04
permissions:
contents: write
id-token: write
packages: write
pull-requests: write
timeout-minutes: 90
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@v10
with:
root-reserve-mb: 30720
temp-reserve-mb: 10240
swap-size-mb: 4096
remove-dotnet: true
remove-android: true
remove-haskell: true
remove-codeql: true
remove-docker-images: true
- name: Check branch
run: echo "${{ github.ref_name }}" | grep -Pq '^release/v3\.\d+\.\d+$'
- name: Get version
id: version
run: |
export VERSION=$(echo ${{ github.ref_name }} | grep -Po '3\.\d+.\d+')
echo "result=$VERSION" >> $GITHUB_OUTPUT
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Insert release date into the changelog
run: |
sed -i "s/^\(## \[.*\] - \)\(unreleased\)$/\1$(date +%Y-%m-%d)/" CHANGELOG.md
set +e
git diff --exit-code --quiet CHANGELOG.md
R=$?
set -e
git config user.name "The Things Bot"
git config user.email "[email protected]"
if [ $R -eq 1 ]; then
git add CHANGELOG.md
git commit -m "all: Enter release date of version ${{ steps.version.outputs.result }} into the changelog"
git push
git tag v${{ steps.version.outputs.result }}
git push origin v${{ steps.version.outputs.result }}
fi
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: "${{ secrets.AWS_REGION }}"
role-to-assume: "arn:aws:iam::${{ secrets.AWS_USER_ID }}:role/${{ secrets.AWS_ROLE_NAME }}"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Install Buf
uses: bufbuild/buf-setup-action@v1
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: "${{ secrets.DOCKERHUB_USERNAME }}"
password: "${{ secrets.DOCKERHUB_PASSWORD }}"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: "${{ secrets.GHCR_USERNAME }}"
password: "${{ secrets.GHCR_PASSWORD }}"
- name: Update APT
run: sudo apt-get -yq update
- name: Install Snapcraft
run: sudo apt-get -yq --no-install-suggests --no-install-recommends install snapcraft
- name: Create Snapcraft folders
run: |
mkdir -p $HOME/.cache/snapcraft/download
mkdir -p $HOME/.cache/snapcraft/stage-packages
- name: Install Go and Dependencies
uses: ./.github/actions/install-go-and-deps
- name: Build Mage
uses: ./.github/actions/build-mage
- name: Install Node and Dependencies
uses: ./.github/actions/install-node-and-deps
- name: Initialize device repository index cache
id: dr-index-cache
uses: actions/cache@v4
with:
path: data/lorawan-devices-index
key: dr-index-cache-${{ hashFiles('data/lorawan-devices') }}
- name: Create device repository index
run: tools/bin/mage dev:initDeviceRepo
if: steps.dr-index-cache.outputs.cache-hit != 'true'
- name: Auto-completion scripts
run: tools/bin/mage cli:autocomplete
timeout-minutes: 5
- name: Build Frontend
uses: ./.github/actions/build-frontend
with:
production-sourcemaps: "true"
- name: Check for diff
run: tools/bin/mage git:diff
- name: Generate Release Notes
run: |
awk '/^## \[${{ steps.version.outputs.result }}\]/{flag=1;next} /^## \[/{flag=0} flag' CHANGELOG.md > /tmp/release-notes.md
- name: Import the signing key
run: |
printf '%s' '${{ secrets.SIGNATURE_PASSPHRASE }}' >/tmp/gpg_passphrase
cat /tmp/gpg_passphrase | gpg --passphrase-fd 0 --no-tty --batch --import gpg_signing_key
- name: Run Goreleaser
uses: goreleaser/goreleaser-action@v5
with:
version: "v1.18.2"
args: release --config .goreleaser.release.yml --release-notes /tmp/release-notes.md --timeout 120m
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_LOGIN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
SIGN_KEY_NAME: ${{ secrets.SIGN_KEY_NAME }}
- name: Determine if released version is latest
id: latest-version
run: |
export LATEST_TAG=$(git tag | grep -P '^v3.\d+\.\d+$' | sort -V | tail -n 1)
set +e
test "$LATEST_TAG" != 'v${{ steps.version.outputs.result }}'
echo "latest=$?" >> $GITHUB_OUTPUT
- name: Tag latest
if: steps.latest-version.outputs.latest == '1'
run: |
export VERSION=$(echo ${{ steps.version.outputs.result }} | grep -Po '3\.\d+')
docker tag ${DOCKER_PREFIX}/lorawan-stack:${VERSION}-amd64 ${DOCKER_PREFIX}/lorawan-stack:latest-amd64
docker tag ${DOCKER_PREFIX}/lorawan-stack:${VERSION}-arm64 ${DOCKER_PREFIX}/lorawan-stack:latest-arm64
docker tag ${DOCKER_PREFIX}/lorawan-stack:${VERSION}-armv7 ${DOCKER_PREFIX}/lorawan-stack:latest-armv7
docker push ${DOCKER_PREFIX}/lorawan-stack:latest-amd64
docker push ${DOCKER_PREFIX}/lorawan-stack:latest-arm64
docker push ${DOCKER_PREFIX}/lorawan-stack:latest-armv7
docker manifest create ${DOCKER_PREFIX}/lorawan-stack:latest ${DOCKER_PREFIX}/lorawan-stack:latest-amd64 ${DOCKER_PREFIX}/lorawan-stack:latest-arm64 ${DOCKER_PREFIX}/lorawan-stack:latest-armv7
docker manifest push ${DOCKER_PREFIX}/lorawan-stack:latest
env:
DOCKER_CLI_EXPERIMENTAL: enabled
DOCKER_PREFIX: thethingsnetwork
- uses: bufbuild/buf-push-action@v1
with:
input: api
buf_token: ${{ secrets.BUF_TOKEN }}
- name: Prepare merge PR
run: |
export PR_URL=$(mktemp)
gh pr create \
--assignee '${{ github.actor }}' \
--base "$(echo ${{ steps.version.outputs.result }} | grep -Po 'v3\.\d+')" \
--body "This pull request merges back changes from the v${{ steps.version.outputs.result }} release." \
--label "release" \
--title "Release v${{ steps.version.outputs.result }}" \
| tee "${PR_URL}"
# Try adding a milestone but ignore errors
gh pr edit < "${PR_URL}" \
--milestone "v${{ steps.version.outputs.result }}" \
|| true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}