upgrade rust to 1.77 and bump docker image version #19
Workflow file for this run
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: | |
push: | |
tags: | |
- "v*" | |
jobs: | |
build: | |
name: Build Srtool Docker image | |
runs-on: ubuntu-latest | |
continue-on-error: false | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
- name: Build image | |
run: | | |
RUSTC_VERSION=$(cat RUSTC_VERSION) | |
echo "RUSTC_VERSION=$RUSTC_VERSION" >> $GITHUB_ENV | |
docker --version | |
docker build $@ --build-arg RUSTC_VERSION=$RUSTC_VERSION -t srtool . | |
docker run -t --rm srtool version -cM | |
- name: Export docker image | |
run: | | |
docker save srtool | gzip > srtool.tar.gz | |
- name: Cache the image | |
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 | |
with: | |
key: srtool-docker-image-${{ github.sha }} | |
path: | | |
srtool.tar.gz | |
create_draft: | |
needs: ["build"] | |
name: Create Draft | |
runs-on: ubuntu-latest | |
outputs: | |
release_url: ${{ steps.create-release.outputs.html_url }} | |
asset_upload_url: ${{ steps.create-release.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 | |
with: | |
fetch-depth: 0 | |
- name: Get Release Version | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV | |
SRTOOL_VERSION=$(cat VERSION) | |
RUSTC_VERSION=$(cat RUSTC_VERSION) | |
echo "SRTOOL_VERSION=$SRTOOL_VERSION" >> $GITHUB_ENV | |
echo "RUSTC_VERSION=$RUSTC_VERSION" >> $GITHUB_ENV | |
- name: Cache the image | |
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 | |
with: | |
key: srtool-docker-image-${{ github.sha }} | |
path: | | |
srtool.tar.gz | |
- name: Install tera-cli | |
run: | | |
URL=https://github.com/chevdor/tera-cli/releases/download/v0.1.3/tera-cli_linux_amd64.deb | |
wget $URL | |
sudo dpkg -i tera-cli_linux_amd64.deb | |
tera --version | |
- name: Generate changelog | |
id: change_log | |
run: | | |
LAST_TAG=$(git describe --tags --abbrev=0 ${{ env.RELEASE_VERSION }}^ ) | |
JSON=$(git log $LAST_TAG..HEAD \ | |
--pretty=format:'{ "commit": "%H", "short_sha": "%h", "author": "%an", "date": "%ad", "message": "%s"},' \ | |
$@ | \ | |
perl -pe 'BEGIN{print "{ \"since\": \"'${LAST_TAG}'\", \"commits\": ["}; END{print "]}"}' | \ | |
perl -pe 's/},]/}]/') | |
echo $JSON | tera --template templates/changelog.md --stdin > changelog.md | |
- name: Render release notes | |
run: | | |
export CHANGELOG=$(cat changelog.md) | |
export REPO=${{ github.REPOSITORY }} | |
export TAG=$RUSTC_VERSION-$SRTOOL_VERSION | |
tera --env --env-only --template templates/release.md > RELEASE_NOTES.md | |
- name: Create Release | |
id: create-release | |
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.RELEASE_VERSION }} | |
release_name: Srtool ${{ env.RUSTC_VERSION }}-${{ env.SRTOOL_VERSION }} (${{ env.SHORT_SHA }}) | |
body_path: ./RELEASE_NOTES.md | |
draft: true | |
publish-docker-image: | |
runs-on: ubuntu-latest | |
needs: ["create_draft"] | |
steps: | |
- name: Cache the image | |
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 # v3.0.11 | |
with: | |
key: srtool-docker-image-${{ github.sha }} | |
path: | | |
srtool.tar.gz | |
- name: Load Docker image | |
run: | | |
docker load -i srtool.tar.gz | |
docker images --digests | |
- name: Get Release Version | |
run: | | |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
echo "SHORT_SHA=${GITHUB_SHA::8}" >> $GITHUB_ENV | |
SRTOOL_VERSION=$(docker run --rm -i srtool version -cM | jq | jq -r .version) | |
RUSTC_VERSION=$(docker run --rm -i srtool version -cM | jq | jq -r .rustc) | |
echo "SRTOOL_VERSION=$SRTOOL_VERSION" >> $GITHUB_ENV | |
echo "RUSTC_VERSION=$RUSTC_VERSION" >> $GITHUB_ENV | |
- name: Tag image | |
env: | |
REPO: ${{ github.REPOSITORY }} | |
run: | | |
docker tag srtool $REPO:$RUSTC_VERSION-$SRTOOL_VERSION | |
docker tag srtool $REPO:$RUSTC_VERSION | |
docker images | |
- name: Log into Docker Hub | |
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push Docker image | |
env: | |
REPO: ${{ github.REPOSITORY }} | |
run: | | |
docker push $REPO:$RUSTC_VERSION-$SRTOOL_VERSION | |
docker push $REPO:$RUSTC_VERSION |