diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a856786..20f3f09 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: continue-on-error: ${{ matrix.checks == 'advisories' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - name: Read rust-toolchain file @@ -44,7 +44,7 @@ jobs: run: | echo "RUST_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - - uses: elastio/actions/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master with: toolchain: ${{ env.RUST_TOOLCHAIN }} components: rustfmt, clippy @@ -66,7 +66,7 @@ jobs: os: [macos-latest, ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - name: Read rust-toolchain file @@ -74,7 +74,7 @@ jobs: run: | echo "RUST_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - - uses: elastio/actions/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master with: toolchain: ${{ env.RUST_TOOLCHAIN }} components: rustfmt, clippy @@ -107,7 +107,7 @@ jobs: os: [ubuntu-latest] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - name: Read rust-toolchain file @@ -115,7 +115,7 @@ jobs: run: | echo "RUST_TOOLCHAIN=$(cat rust-toolchain)" >> $GITHUB_ENV - - uses: elastio/actions/rust-toolchain@v1 + - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master with: toolchain: ${{ env.RUST_TOOLCHAIN }} components: rustfmt, clippy @@ -139,12 +139,15 @@ jobs: RUSTC_BOOTSTRAP: 1 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - - uses: actions-rs/toolchain@v1 + # The repo is public and can not use the private elastio/actions. + - id: toolchain + run: echo "version=$(cat rust-toolchain)" >> "$GITHUB_OUTPUT" + - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master with: - profile: minimal + toolchain: ${{ steps.toolchain.outputs.version }} - run: git config --global credential.helper store && echo https://token:${{ secrets.PRIVATE_REGISTRY_TOKEN }}@dl.cloudsmith.io > $HOME/.git-credentials - run: sudo apt-get install -y linux-headers-$(uname -r) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f534604..d539e78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,12 +28,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - - uses: actions-rs/toolchain@v1 + # The repo is public and can not use the private elastio/actions. + - id: toolchain + run: echo "version=$(cat rust-toolchain)" >> "$GITHUB_OUTPUT" + - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master with: - profile: minimal + toolchain: ${{ steps.toolchain.outputs.version }} components: rustfmt, clippy - run: git config --global credential.helper store && echo https://token:${{ secrets.PRIVATE_REGISTRY_TOKEN }}@dl.cloudsmith.io > $HOME/.git-credentials @@ -47,41 +50,58 @@ jobs: # Publishing happens only on pushes to master. Other branches and PRs don't count if: ${{ github.ref == 'refs/heads/master' }} runs-on: ubuntu-latest + # The key of the elastio-release App is in this environment, for master only. + environment: release # This job must execute only if all checks pass! needs: - rust-lint env: + ELASTIO_GIT_COMMIT_AUTHOR_NAME: elastio-release[bot] + ELASTIO_GIT_COMMIT_AUTHOR_EMAIL: 363618334+elastio-release[bot]@users.noreply.github.com CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_TOKEN }} steps: - # NASTY: This token must be the PAT of a user who has admin access to the repo - # in order to bypass branch protections and commit directly to master. - - uses: actions/checkout@v3 + # The release commit and tag are pushed with the token that checkout stores. + - name: Mint the token of the elastio-release App + id: app + uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0 + with: + app-id: ${{ vars.ELASTIO_RELEASE_APP_ID }} + private-key: ${{ secrets.ELASTIO_RELEASE_PRIVATE_KEY }} + permission-contents: write + + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 with: submodules: recursive - token: ${{ secrets.TSAR_FERRIS_GITHUB_TOKEN }} + token: ${{ steps.app.outputs.token }} - - uses: actions-rs/toolchain@v1 + # The repo is public and can not use the private elastio/actions. + - id: toolchain + run: echo "version=$(cat rust-toolchain)" >> "$GITHUB_OUTPUT" + - uses: dtolnay/rust-toolchain@df2a88e9fe4098bad09cb42c3dec7187f15861fc # master with: - profile: minimal + toolchain: ${{ steps.toolchain.outputs.version }} # Install cloudsmith CLI via pip - - uses: actions/setup-python@v4 + - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 + with: + python-version: "3.12" - run: pip install cloudsmith-cli # A committer identity is required in order to commit things - run: | - git config user.name "Tsar Ferris" - git config user.email tsar-ferris@elastio.com + git config user.name "elastio-release[bot]" + git config user.email "363618334+elastio-release[bot]@users.noreply.github.com" - run: git config --global credential.helper store && echo https://token:${{ secrets.PRIVATE_REGISTRY_TOKEN }}@dl.cloudsmith.io > $HOME/.git-credentials - name: Install xelastio - uses: elastio/actions/install@v1 - with: - tool: xelastio + run: | + curl --location --silent --fail --show-error --retry 5 \ + https://dl.cloudsmith.io/public/elastio/public/raw/versions/latest/cargo-xelastio_x86_64-unknown-linux-musl.tar.xz \ + | tar --extract --xz --directory "$HOME/.cargo/bin" # Perform the actual release operations - run: cargo xelastio publish release ${{ github.event.inputs.bumpLevel }}